﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DNASequencing.core.Algorithms;
using DNASequencing.core.data;
using DNASequencing.core.Algorithms.rating;

namespace DNASequencing.core.Algorithms
{
    abstract class AAlgorithm
    {
        protected int k;

        protected int n;

        protected ADataTree dt;

        protected IRating rating;

        protected List<Oligonucleotide> best = new List<Oligonucleotide>();

        protected List<Oligonucleotide> _oAll = new List<Oligonucleotide>();

        public AAlgorithm(int k, int n, ADataTree dt, IRating rating)
        {
            this.k = k;
            this.n = n;
            this.dt = dt;
            this.rating = rating;

            foreach (AOligonucleotide o in dt.all)
                _oAll.Add(new Oligonucleotide(o));
        }

        public int negativeError
        {
            get
            {
                if (best.Count == 0)
                    return -1;
                else
                    return SequenceUtils.extractNegativeError(best);
            }
        }

        public int positiveError
        {
            get
            {
                if (best.Count == 0)
                    return -1;
                else
                    return SequenceUtils.extractPositiveError(best, _oAll);
            }
        }

        abstract public AlgorithmResult process();
    }
}
